package atguigu.SPI;

import java.util.Iterator;
import java.util.ServiceLoader;

public class TestMain {

    public static void main(String[] args) {

        // 类路径下的META-INF\services
        // 接口的全类名作为文件名，里面的类容也是接口实现类的全类名
        // 例如这里的文件：atguigu.SPI.uploadCDN ，里面的内容
        // atguigu.SPI.QiyiCDN
        // atguigu.SPI.ChinaNetCDN
        ServiceLoader<UploadCDN> uploadCDN = ServiceLoader.load(UploadCDN.class);
        Iterator<UploadCDN> iterator = uploadCDN.iterator();
        while (iterator.hasNext()) {
            UploadCDN next = iterator.next();
            System.out.println(next.toString());
            next.upload("filepath");
        }
    }
}
